from selenium import webdriver
import time
from pprint import pprint


class Case:
    def __init__(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://www.baidu.com')
        time.sleep(1)

    def cookies(self):
        pprint(self.driver.get_cookies())

    def cookie(self, name):
        pprint(self.driver.get_cookie(name))

    def add_cookie(self):
        cookie = {
            'name': 'hello',
            'value': '你好'
        }
        self.driver.add_cookie(cookie)

    def delete(self):
        self.driver.delete_cookie('hello')


if __name__ == '__main__':
    case = Case()
    # case.cookies()
    case.cookie('ZFY')
    case.add_cookie()
    case.cookies()
